<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<th:block th:insert="~{include :: header('紫卡倾向')}"/>
<th:block th:insert="~{include :: bootstrap-select-css}"/>
<style>
    a img {
        width: 50px;
        display: block;
    }

    a:hover img {
        transform: scale(3);
    }
</style>
<body>
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="rivenTrend-form">
                <div class="select-list">
                    <ul>
                        <li>
                            <label for="itemName">物品名称： </label><input class="form-control" name="itemName" id="itemName"
                                                            placeholder="itemName"
                                                            type="text"/>
                        </li>
                        <li>
                            <a class="btn btn-success btn-rounded btn-sm" onclick="searchPre()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="container-div">
            <div class="row">
                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-primary btn-rounded btn-sm" onclick="init()">
                        <i class="fa fa-angle-up"></i> 初始化
                    </a>
                    <a class="btn btn-primary btn-rounded btn-sm" onclick="update()">
                        <i class="fa fa-angle-up"></i> 更新
                    </a>
                    <a class="btn btn-success" onclick="$.operate.add(undefined,300,450)">
                        <i class="fa fa-plus"></i> 新增
                    </a>
                    <a class="btn btn-warning" onclick="push()">
                        <i class="fa fa-download"></i> 推送到Github
                    </a>
                </div>
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<th:block th:insert="~{include :: footer}"/>
<th:block th:insert="~{include :: bootstrap-select-js}"/>
<script th:inline="javascript">
    const prefix = ctx + "data/warframe/rivenTrend";
    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            modalName: "紫卡倾向",
            sortOrder: "desc",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            columns: [
                {
                    field: 'state',
                    radio: true
                },
                {
                    field: 'id',
                    title: 'ID'
                },
                {
                    field: 'trend_name',
                    title: '物品名称'
                },
                {
                    field: 'traCh',
                    title: '物品名称'
                },
                {
                    field: 'new_num',
                    title: '新的倾向'
                },
                {
                    field: 'old_num',
                    title: '旧的倾向'
                },
                {
                    field: 'type',
                    title: '武器类型'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row) {
                        const actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(' + row.id + ',' + 300 + ',' + 450 + ')"><i class="fa fa-edit"></i>修改</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });

    function searchPre() {
        $.table.search('rivenTrend-form', 'bootstrap-table');
    }

    function update() {
        $.operate.post(prefix + "/update")
    }

    function init() {
        $.operate.post(prefix + "/init")
    }

    function push() {
        $.modal.open("推送", prefix + "/push", 300, 300);
    }

    function resetPre() {
        $("#rivenTrend-form")[0].reset();
        $.table.search('rivenTrend-form', 'bootstrap-table');
    }

</script>

</body>
</html>